
import { ref, reactive, provide, nextTick, watch } from "vue";
import type { FormInstance, FormRules } from "element-plus";
import { ElMessage } from 'element-plus'
import { ResultEnum } from "@/enums/httpEnum";
import { getGoodsTypeInitApi, saveGoodsTypeTableDataApi, saveGoodsClassDataApi } from "@/api/modules/goodsArchive/set/goodsType.ts";
import { IgoodsTypeForm, IClassIdFrom, IOptionStr_Num, IsearchForm } from "./interface.ts"
let $t = '';//language


//组件上下文
const goodsTypeContext = {
    goodsGroupDialogShowFn: '',//添加商品类型表单，平级打开商品分组模态
    addClassGroupUpdateGoodsTypeFormData: '',//添加新分组 ，平级更能 添加商品类型表单分组数据
    addGoodsTypeDarwerShowFn: '',//等于 UseAddGoodsTypeModule showFormDrawerFn
    updataSearchBarSetInitBusinessData: '',//搜索栏初始化数据会在getInitData中赋值
    refreshTable: null,
    searchValueClear: ''//调用搜索栏清空搜索值
}

//页面公共数据,这里的数据不是响应式的
const publicBusinessData = {
    initData: {}
}

//获取公共数据,
const getInitData = async (parame) => {
    await getGoodsTypeInitApi(parame).then(res => {
        if (res.code == ResultEnum.SUCCESS) {
            publicBusinessData.initData = { ...res.data };
            goodsTypeContext.updataSearchBarSetInitBusinessData()
        }
    })
}

// 高级搜索模块
import searchBarCompoent from "./component/adSerachComponent/index.vue";
export const UseSearchModule = () => {
    const searchBarRef: { el: string } = { el: '' }//存储form表单proxy，添加依赖到表单，修改注入el，以保证抽屉弹出后可以访问表单实例
    const searchValue = ref('');


    const serachFormRules = {
        "type_name.value": [],
        "type_name_cn.value": [],
        "type_name_en.value": [],
        "tag.value": [],
        "class_id.value": [],
        "has_color.value": [],
        "has_gender.value": [],
        "has_size.value": [],
        "package_type.value": []
    }
    const hasOptions = ref<IOptionStr_Num[]>([
        // { label: "有", value: 1 },
        // { label: "无", value: 0 }
    ]);

    const packageTypeOptions = ref<IOptionStr_Num[]>([
        // { label: "单尺码", value: 0 },
        // { label: "多尺码", value: 1 }

    ]);

    const classIdOptions = ref<IOptionStr_Num[]>([
        // { label: "鞋", value: 0 },
        // { label: "包", value: 1 },
        // { label: "毛巾", value: 1 }

    ]);
    const tagOptions = ref<IOptionStr_Num[]>([
        // { label: "鞋", value: 0 },
        // { label: "包", value: 1 },
        // { label: "毛巾", value: 1 }

    ]);
    //尺码/规格属性options数据
    const sizePropId = ref<IOptionStr_Num[]>([
        // {
        //     label: "尺码", value: 217
        // }
    ]);

    const searchFormData = reactive<IsearchForm>({
        type_name: {//商品类型俄文
            type: 'input',
            label: $t('archive_set_goods_type.archive_goods_type_quick_serch'),
            value: '',
            placeholder: $t('archive_set_goods_type.archive_goods_type_quick_serch_placeholder'),

        },
        class_id: {//商品类型分组
            type: 'select',
            label: $t('archive_set_goods_type.class_id'),
            value: '',
            placeholder: $t('archive_set_goods_type.class_id_placeholder'),

            options: classIdOptions
        },
        has_color: {//是否有颜色
            type: 'select',
            label: $t('archive_set_goods_type.has_color'),
            value: '',
            placeholder: $t('archive_set_goods_type.has_color_placeholder'),
            options: hasOptions
        },
        has_gender: {//是否有性别
            type: 'select',
            label: $t('archive_set_goods_type.has_gender'),
            value: '',
            placeholder: $t('archive_set_goods_type.has_gender_placeholder'),
            options: hasOptions
        },
        has_size: {//是否有规格
            type: 'select',
            label: $t('archive_set_goods_type.has_size'),
            value: '',
            placeholder: $t('archive_set_goods_type.has_size_placeholder'),
            options: hasOptions
        },
        tag: {//商品类型标签
            type: 'select',
            label: $t('archive_set_goods_type.tag'),
            value: '',
            placeholder: $t('archive_set_goods_type.tag_placeholder'),
            options: tagOptions
        },
        package_type: {//商品套装格式
            type: 'select',
            label: $t('archive_set_goodsType.package_type'),
            value: '',
            placeholder: $t('archive_set_goods_type.package_type_placeholder'),
            options: packageTypeOptions
        },
        // unit: {// 商品单位
        //     type: 'input',
        //     label: $t('archive_set_goodsType.unit'),
        //     value: '',
        //     placeholder: $t('archive_set_goods_type.package_type_placeholder'),

        // }

    });

    //业务--设置初始化表单业务数据 添加表单和这里有相同的数据，修改时候需同步修改
    const setInitBusinessData = (): Promise<void> => {
        hasOptions.value = publicBusinessData.initData?.dataarr?.has_color;
        packageTypeOptions.value = publicBusinessData.initData?.dataarr?.package_type;
        classIdOptions.value = publicBusinessData.initData?.dataarr?.class_id;
        tagOptions.value = publicBusinessData.initData?.dataarr?.tag;
        sizePropId.value = publicBusinessData.initData?.dataarr?.size_prop_id;
        return Promise.resolve();
    }

    //关闭搜索模态框
    const searchCloseModal = (): Promise<void> => {
        let searchEl = searchBarRef.el;
        setTimeout(() => {
            searchEl.value.modalHide();
        }, 500)
        return Promise.resolve();
    }
    //重置表单数据
    const searchResetForm = (): Promise<void> => {
        let searchEl = searchBarRef.el;
        Object.keys(searchFormData).map(key => {
            searchFormData[key].value = '';
        })
        submitForm()
        searchEl.value.clear();
        searchEl.value.modalHide();

        return Promise.resolve();
    }
    //快速搜索
    const searchQuickForm = (params): Promise<void> => {
        let searchEl = searchBarRef.el;
        Object.keys(searchFormData).map(key => {
            searchFormData[key].value = '';
        })
        goodsTypeContext.refreshTable({ type_name: params.type_name });

        return Promise.resolve();
    }

    //搜索表单提交
    const submitForm = async () => {
        let searchEl = searchBarRef.el;
        const postData = {};
        Object.keys(searchFormData).map(key => {
            postData[key] = searchFormData[key].value + ""
        })
        goodsTypeContext.refreshTable(postData).then(res => {
            searchCloseModal()
        })
        searchEl.value.clear();
    };


    const openGoodsTypeDarwer = () => {
        goodsTypeContext.addGoodsTypeDarwerShowFn()
    }


    provide("searchBarRef", searchBarRef);//注入实例ref，search组件会修改searchBarRef.el
    provide("searchValue", searchValue);// 
    provide("searchFormData", searchFormData);//注入搜索组件表单数据
    provide("serachFormRules", serachFormRules);//注入搜索组件验证规则
    provide("serachFormHasOptions", hasOptions);
    provide("serachFormClassIdOptions", classIdOptions);//注入搜索组件分组数据
    provide("serachFormTagOptions", tagOptions);//注入搜索组件标签数据
    provide("serachFormPackageTypeOptions", packageTypeOptions);//注入搜索组件套装格式数据
    provide("serachOpenGoodsTypeDarwer", openGoodsTypeDarwer); //打开添加商品类型表单
    provide("searchCloseModalFn", searchCloseModal); //关闭modal
    provide("searchResetForm", searchResetForm); //重置数据
    provide("searchSubmitFormModalFn", submitForm); //提交搜索
    provide("searchBarPost", searchQuickForm); //提交搜索

    goodsTypeContext.updataSearchBarSetInitBusinessData = setInitBusinessData
    goodsTypeContext.searchValueClear = searchResetForm
    return {
        searchBarCompoent
    }

}

// 添加新商品类型模块
import addGoodsTypeFormComponent from "./component/addGoodsType/index.vue";
export const UseAddGoodsTypeModule = (proxy) => {
    const drawerIsShow = ref<boolean>(false);//抽屉显示状态
    const formRef: { el: string } = { el: '' }//存储form表单proxy，添加依赖到表单，修改注入el，以保证抽屉弹出后可以访问表单实例
    // 表单数据
    const goodsTypeFormDataReactive = reactive<IgoodsTypeForm>({
        "type_id": {
            label: $t("archive_set_goods_type.type_id"),
            value: '',
            placeholder: "商品类型ID"
        },
        "type_name": {
            label: $t("archive_set_goods_type.type_name"),
            value: "",
            placeholder: $t("archive_set_goods_type.type_name_placeholder"),//商品类型俄
        },
        "type_name_cn": {
            label: $t("archive_set_goods_type.type_name_cn"),
            value: "",
            placeholder: $t("archive_set_goods_type.type_name_cn_placeholder"),//商品类型中
        },

        "type_name_en": {
            label: $t("archive_set_goods_type.type_name_en"),
            value: "",
            placeholder: $t("archive_set_goods_type.type_name_en_placeholder"),//商品类型英
        },
        "unit": {
            label: $t("archive_set_goods_type.unit"),//最小销售单位名称
            value: "",
            placeholder: $t("archive_set_goods_type.unit_placeholder"),
        },
        "unit_cn": {
            label: $t("archive_set_goods_type.unit_cn"),//最小销售单位名称（中）
            value: "",
            placeholder: $t("archive_set_goods_type.unit_cn_placeholder"),
        },
        "multi_unit": {
            label: $t("archive_set_goods_type.multi_unit"),//套装单位名称
            value: "",
            placeholder: $t("archive_set_goods_type.multi_unit_placeholder"),
        },
        "multi_unit_cn": {
            label: $t("archive_set_goods_type.multi_unit_cn"),
            value: "",
            placeholder: $t("archive_set_goods_type.multi_unit_cn_placeholder"),
        },
        "has_gender": {
            label: $t("archive_set_goods_type.has_gender"),//是否性别
            value: 1,
            placeholder: $t("archive_set_goods_type.has_gender_placeholder"),
        },
        // 请选择是否有颜色
        "has_color": {
            label: $t("archive_set_goods_type.has_color"),//是否有颜色
            value: 1,
            placeholder: $t("archive_set_goods_type.has_color_placeholder"),
        },
        "has_size": {
            label: $t("archive_set_goods_type.has_size"),//是否有规格
            value: 1,
            placeholder: $t("archive_set_goods_type.has_size_placeholder"),
        },
        "package_type": {
            label: $t("archive_set_goods_type.package_type"),//套装格式
            value: '',
            placeholder: $t("archive_set_goods_type.package_type_placeholder"),
            show: true
        },
        "class_id": {
            label: $t("archive_set_goods_type.class_id"), //分组
            value: '',
            placeholder: $t("archive_set_goods_type.class_id_placeholder"),
        },
        "tag": {
            label: $t("archive_set_goods_type.tag"),//标签
            value: "",
            placeholder: $t("archive_set_goods_type.tag_placeholder"),
        },
        "size_prop_id": {
            label: $t("archive_set_goods_type.size_prop_id"),//尺码/规格属性
            value: '',
            placeholder: $t("archive_set_goods_type.size_prop_id_placeholder"),
        },
    });

    //表单校验 rules
    const rules = reactive<FormRules>({
        "type_id.value": [
            { required: true, message: goodsTypeFormDataReactive.type_id.placeholder, trigger: 'change' },
        ],
        "type_name.value": [
            { required: true, message: goodsTypeFormDataReactive.type_name.placeholder, trigger: 'change' },
        ],
        "type_name_cn.value": [
            { required: true, message: goodsTypeFormDataReactive.type_name_cn.placeholder, trigger: 'change' },
        ],

        "type_name_en.value": [
            { required: true, message: goodsTypeFormDataReactive.type_name_en.placeholder, trigger: 'change' },
        ],

        "unit.value": [
            { required: true, message: goodsTypeFormDataReactive.unit.placeholder, trigger: 'change' },
        ],
        "unit_cn.value": [
            { required: true, message: goodsTypeFormDataReactive.unit_cn.placeholder, trigger: 'change' },
        ],

        "multi_unit.value": [
            { required: true, message: goodsTypeFormDataReactive.multi_unit.placeholder, trigger: 'change' },
        ],
        "multi_unit_cn.value": [
            { required: true, message: goodsTypeFormDataReactive.multi_unit_cn.placeholder, trigger: 'change' },
        ],
        "has_gender.value": [
            { required: true, message: goodsTypeFormDataReactive.has_gender.placeholder, trigger: 'change' },
        ],
        "has_color.value": [
            { required: true, message: goodsTypeFormDataReactive.has_color.placeholder, trigger: 'change' },
        ],
        "has_size.value": [
            { required: true, message: goodsTypeFormDataReactive.has_size.placeholder, trigger: 'change' },
        ],
        "package_type.value": [
            { required: true, message: goodsTypeFormDataReactive.package_type.placeholder, trigger: 'change' },
        ],
        "class_id.value": [
            { required: true, message: goodsTypeFormDataReactive.class_id.placeholder, trigger: 'change' },
        ],
        "tag.value": [
            { required: false, message: goodsTypeFormDataReactive.tag.placeholder, trigger: 'change' },
        ],
        "size_prop_id.value": [
            { required: false, message: goodsTypeFormDataReactive.size_prop_id.placeholder, trigger: 'change' },
        ],


    })


    //有无选项 options 公用数据
    const hasOptions = ref<IOptionStr_Num[]>([
        // { label: "有", value: 1 },
        // { label: "无", value: 0 }
    ]);

    //套装格式下拉options数据
    const packageTypeOptions = ref<IOptionStr_Num[]>([
        // { label: "单尺码", value: 0 },
        // { label: "多尺码", value: 1 }

    ]);

    //分组options数据
    const classIdOptions = ref<IOptionStr_Num[]>([
        // { label: "鞋", value: 0 },
        // { label: "包", value: 1 },
        // { label: "毛巾", value: 1 }

    ]);

    //标签options数据
    const tagOptions = ref<IOptionStr_Num[]>([
        // { label: "鞋", value: 0 },
        // { label: "包", value: 1 },
        // { label: "毛巾", value: 1 }

    ]);
    //尺码/规格属性options数据
    const sizePropId = ref<IOptionStr_Num[]>([
        // {
        //     label: "尺码", value: 217
        // }
    ]);

    //业务-- 监听 has_size 改变，无 =》套装格式 不必填,默认值 无，有=》套装格式必填
    watch(() => goodsTypeFormDataReactive.has_size.value, (val) => {
        if (val == 0) {//无
            goodsTypeFormDataReactive.package_type.value = -1;
            goodsTypeFormDataReactive.package_type.show = false;
        } else {
            goodsTypeFormDataReactive.package_type.show = true;
        }
    })


    //业务--设置初始化表单业务数据 高级搜索和这里有相同的数据，修改时候需同步修改
    const setInitBusinessData = (): Promise<void> => {
        hasOptions.value = publicBusinessData.initData?.dataarr?.has_color;
        packageTypeOptions.value = publicBusinessData.initData?.dataarr?.package_type;
        classIdOptions.value = publicBusinessData.initData?.dataarr?.class_id;
        tagOptions.value = publicBusinessData.initData?.dataarr?.tag;
        sizePropId.value = publicBusinessData.initData?.dataarr?.size_prop_id;
        return Promise.resolve();
    }
    //业务--设置初始化表单默认值数据
    const setInitBusinessDataDefaultValue = (): Promise<void> => {
        const defaultValueDataObject = publicBusinessData.initData?.defaults;
        let reg = /_txt$/ig;
        Object.keys(defaultValueDataObject).forEach((key: string) => {

            if (!reg.test(key)) {
                goodsTypeFormDataReactive[key].value = defaultValueDataObject[key];
            }

        })


        return Promise.resolve();
    }
    //业务--添加新分组后同步goodsTypeFormDataReactive class_id 数据
    const updateclassIdData = (data) => {
        classIdOptions.value = data.classArr;
        goodsTypeFormDataReactive.class_id.value = data.class_id;
    }
    //关闭添加商品抽屉
    const hideFormDrawerFn = async (): Promise<void> => {

        publicBusinessData.initData.defaults = {};
        await resetFieldsFn();
        await clearValidateFn();
        drawerIsShow.value = false;
        return Promise.resolve();
    }
    //打开添加商品抽屉
    const showFormDrawerFn = async (): Promise<void> => {
        await setInitBusinessData();//设置表单基础数据
        await setInitBusinessDataDefaultValue();//设置表单默认值数据
        goodsTypeFormDataReactive.type_id.value = ''
        drawerIsShow.value = true;
        return Promise.resolve();
    };
    //编辑添加商品抽屉
    const editFormDrawerFn = async (row): Promise<void> => {
        await getInitData({ "type_id": row.type_id ?? "" });
        await setInitBusinessData();//设置表单基础数据
        await setInitBusinessDataDefaultValue();//设置表单默认值数据
        drawerIsShow.value = true;
        return Promise.resolve();
    };

    //打开抽屉后回调
    const formDrawerOpenedFn = (): Promise<void> => {
        clearValidateFn();
        return Promise.resolve();
    };
    //关闭抽屉后回调
    const formDrawerClosedFn = async (): Promise<void> => {

        return Promise.resolve();
    };

    //验证表单
    const validateFormFn = async (): Promise<{}> => {
        let formEle: FormInstance = formRef.el.value;
        let validReuslt: object = { error: "UseAddGoodsTypeModule -> goodsTypeFormRef-> 没有获取到表单实例" };
        if (formEle) {
            await formEle.validate((valid, fields) => {
                validReuslt = { valid, fields };
                if (valid) {
                    return true
                } else {
                    return false
                }
            });

        }
        return Promise.resolve(validReuslt);
    }

    //清除表单验证
    const clearValidateFn = (): Promise<void> => {
        let formEle: FormInstance = formRef.el.value;
        if (formEle) {
            formEle.clearValidate();
        }
        return Promise.resolve();
    }
    //重置表单默认
    const resetFieldsFn = (): Promise<void> => {
        let formEle: FormInstance = formRef.el.value;


        if (formEle) {
            formEle.resetFields();
        }
        Object.keys(goodsTypeFormDataReactive).map(item => {

            goodsTypeFormDataReactive[item].value = '';


        })
        return Promise.resolve();
    }

    //业务--添加商品类型表单-->添加商品表单提交,保存数据
    const saveGoodsTypeFormFn = async () => {
        await validateFormFn().then(res => {
            if (res.valid) {//表单验证通过
                let postData = {};
                Object.keys(goodsTypeFormDataReactive).map(item => {
                    if (goodsTypeFormDataReactive[item].value == 'undefined' || goodsTypeFormDataReactive[item].value == undefined) {
                        postData[item] = goodsTypeFormDataReactive[item].value = '';
                    }
                    postData[item] = goodsTypeFormDataReactive[item].value + '';

                })
                saveGoodsTypeTableDataApi(postData).then(res => {
                    if (res.code == ResultEnum.SUCCESS) {
                        ElMessage.success($t('merak.action_success'));
                        // goodsTypeContext.refreshTable();
                        goodsTypeContext.searchValueClear()
                        hideFormDrawerFn();
                    } else {
                        ElMessage.error(res.message);
                    }
                });
            }

        });
    };


    //添加商品类型表单-->添加商品分组,这里调用添加商品分类组件
    const addClassGroupFn = async (): Promise<void> => {
        goodsTypeContext.goodsGroupDialogShowFn();
        return Promise.resolve()
    };


    goodsTypeContext.addClassGroupUpdateGoodsTypeFormData = updateclassIdData;//暴露全局方法，其它组件会调用
    goodsTypeContext.addGoodsTypeDarwerShowFn = showFormDrawerFn;//暴露全局方法，其它组件会调用


    //依赖给添加商品类型组件,复用必须传入下面三行数据 
    provide('goodsTypeFormData', goodsTypeFormDataReactive);//添加了类型表单数据
    provide('hasOptions', hasOptions);//添加依赖了类型表单 有无选项 options 公共数据，所有有无都会使用这个
    provide('packageTypeOptions', packageTypeOptions);//添加依赖了类型表单 套装选项 options
    provide('classIdOptions', classIdOptions);//添加依赖了类型表单 分组选项 options
    provide('tagOptions', tagOptions);//添加依赖了类型表单 标签选项 options
    provide('sizePropId', sizePropId);//添加依赖了类型表单 套装选项 options
    provide('rules', rules);
    provide('goodsTypeDrawerIsShow', drawerIsShow);
    provide('goodsTypeHideFormDrawerFn', hideFormDrawerFn);
    provide('formDrawerClosedFn', formDrawerClosedFn);
    provide('formDrawerOpenedFn', formDrawerOpenedFn);
    provide('addClassGroupFn', addClassGroupFn);
    provide('saveGoodsTypeFormFn', saveGoodsTypeFormFn);
    provide('goodsTypeFormRef', formRef);


    return {
        addGoodsTypeFormComponent,
        goodsTypeFormDataReactive,
        hasOptions,
        classIdOptions,
        hideFormDrawerFn,
        showFormDrawerFn,
        editFormDrawerFn,
        formDrawerOpenedFn,
        formDrawerClosedFn,
        saveGoodsTypeFormFn,
        addClassGroupFn,
        validateFormFn,
        clearValidateFn,
        drawerIsShow
    }

}

//添加新商品分组
import addGoodsGroupFormComponent from "./component/addGoodsGroup/index.vue";
export const UseAddGoodsGroupModule = () => {

    const dialogIsShow = ref<boolean>(false);//模态显示状态
    const goodsGroupFormRef: { el: string } = { el: '' }//存储form表单proxy，添加依赖到表单，修改注入el，以保证抽屉弹出后可以访问表单实例

    //   表单数据
    const classIdFormDataReactive = reactive<IClassIdFrom>({
        "class": {
            label: $t("archive_set_goods_type.class"),//商品分组名称(俄语)
            value: '',
            placeholder: $t("archive_set_goods_type.class_placeholder")
            //  "商品分组(俄语)"
        },
        "class_cn": {
            label: $t("archive_set_goods_type.class_cn"),//"商品分组名称(中文)",
            value: '',
            placeholder: $t("archive_set_goods_type.class_cn_placeholder")
            //"商品分组(中文)"
        }
    });
    //表单验证
    const classIdFormDataRules = reactive<FormRules>({
        "class_name.value": [
            { required: true, message: classIdFormDataReactive.class.placeholder, trigger: 'change' },
        ],
        "class_name_cn.value": [
            { required: true, message: classIdFormDataReactive.class_cn.placeholder, trigger: 'change' },
        ]
    });
    //清除表单验证
    const clearValidateFn = (): Promise<void> => {
        let formEle: FormInstance = goodsGroupFormRef.el.value;
        if (formEle) {
            formEle.clearValidate();
        }
        return Promise.resolve();
    }

    //打开模态框
    const goodsGroupDialogShowFn = () => {
        dialogIsShow.value = true;
    }
    //模态框取消
    const goodsGroupDialogcancelFn = () => {
        let formEle: FormInstance = goodsGroupFormRef.el.value;
        clearValidateFn(formEle)
        dialogIsShow.value = false;
    }
    //模态框确认
    const goodsGroupDialogConfirmFn = async () => {
        let formEle: FormInstance = goodsGroupFormRef.el.value;
        if (!formEle) return
        const postData = {
            class: classIdFormDataReactive.class.value,
            class_cn: classIdFormDataReactive.class_cn.value,
        }
        await formEle.validate((valid, fields) => {
            if (valid) {
                saveGoodsClassDataApi(postData).then(res => {
                    if (res.code == ResultEnum.SUCCESS) {
                        ElMessage.success($('archive_set_goods_type.add_class_success_tips'));
                        // ElMessage.success('添加新商品分组成功');
                        //更新商品分组数据
                        goodsTypeContext.addClassGroupUpdateGoodsTypeFormData(res.data);
                        goodsGroupDialogcancelFn();

                    } else {
                        ElMessage.error(res.message || '')
                    }


                })
            } else {
                console.log('error submit!', fields)
            }
        })
        // dialogIsShow.value = false;
    }

    //依赖给添加商品类型组件,复用必须传入下面数据 
    provide('classIdFormData', classIdFormDataReactive);
    provide('classIdFormDataRules', classIdFormDataRules);
    provide('dialogIsShow', dialogIsShow);
    provide('goodsGroupDialogcancelFn', goodsGroupDialogcancelFn);
    provide('goodsGroupDialogConfirmFn', goodsGroupDialogConfirmFn);
    provide('goodsGroupFormRef', goodsGroupFormRef);


    // 组件间调用对象，这里暴露给模块作用域打开表单方法
    goodsTypeContext.goodsGroupDialogShowFn = goodsGroupDialogShowFn;

    return {
        addGoodsGroupComponent: addGoodsGroupFormComponent,
        dialogIsShow,
        classIdFormDataReactive,
        goodsGroupDialogConfirmFn,
        goodsGroupDialogcancelFn
    }
}

//初始化商品设置
export const UserAddGoodsTypeInit = async (proxy, refreshTableFn): Promise<void> => {
    $t = proxy.$t;
    await getInitData();
    goodsTypeContext.refreshTable = refreshTableFn
    return Promise.resolve()
}




